package com.example.lock.entity;

import com.example.lock.zk.ZKLock;
import com.example.util.TranslationUtils;
import lombok.Data;
import org.springframework.transaction.TransactionStatus;

/**
 * @Description: 锁的信息实体类
 * @Author: mingtian
 * @CreateDate: 2020/12/7 16:01
 * @Version: 1.0
 */
@Data
public class LockInfo {

    /**
     * 锁的 id
     */
    private String lockId;

    /**
     * 当前线程信息
     */
    private Thread lockThread;

    /**
     * 线程状态 start 开始状态  stop 停止状态
     */
    private String state;

    /**
     * 保存分布式锁
     */
    private ZKLock lock;

    /**
     * 记录事务信息
     */
    private TranslationUtils translationUtils;

    /**
     * 事务信息
     */
    private TransactionStatus transactionStatus;

    public LockInfo(String lockId, Thread lockThread, String state, ZKLock lock) {
        this.lockId = lockId;
        this.lockThread = lockThread;
        this.state = state;
        this.lock = lock;
    }

    public LockInfo(String lockId, Thread lockThread, String state, ZKLock lock, TranslationUtils translationUtils, TransactionStatus transactionStatus) {
        this.lockId = lockId;
        this.lockThread = lockThread;
        this.state = state;
        this.lock = lock;
        this.translationUtils = translationUtils;
        this.transactionStatus = transactionStatus;
    }
}